package com.knowledgeqa.system.common;

/**
 * 结果码枚举类
 * 定义系统中所有的状态码和对应的消息
 */
public enum ResultCode {
    // 成功状态码
    SUCCESS(200, "操作成功"),

    // 客户端错误状态码 4xx
    PARAM_ERROR(400, "参数错误"),
    UNAUTHORIZED(401, "未授权，请登录"),
    FORBIDDEN(403, "权限不足"),
    NOT_FOUND(404, "请求的资源不存在"),
    METHOD_NOT_ALLOWED(405, "不支持的请求方法"),

    // 服务器错误状态码 5xx
    SYSTEM_ERROR(500, "系统内部错误"),
    SERVICE_UNAVAILABLE(503, "服务不可用"),

    // 业务错误状态码 1xxx
    USER_NOT_EXIST(1001, "用户不存在"),
    USER_ALREADY_EXIST(1002, "用户已存在"),
    USERNAME_OR_PASSWORD_ERROR(1003, "用户名或密码错误"),
    PASSWORD_ERROR(1004, "密码错误"),
    USER_STATUS_ERROR(1005, "用户状态异常"),

    // 金币相关错误状态码 11xx
    COIN_INSUFFICIENT(1101, "金币余额不足"),
    COIN_TRANSACTION_FAILED(1102, "金币交易失败"),

    // 问答相关错误状态码 12xx
    QUESTION_NOT_EXIST(1201, "问题不存在"),
    QUESTION_STATUS_ERROR(1202, "问题状态异常"),
    ANSWER_NOT_EXIST(1203, "回答不存在"),
    ANSWER_STATUS_ERROR(1204, "回答状态异常"),
    CANNOT_DELETE_ANSWERED_QUESTION(1205, "已有回答的问题不能删除"),

    // 验证码相关错误状态码 13xx
    CAPTCHA_ERROR(1301, "验证码错误"),
    CAPTCHA_EXPIRED(1302, "验证码已过期"),

    // 文件相关错误状态码 14xx
    FILE_UPLOAD_ERROR(1401, "文件上传失败"),
    FILE_SIZE_EXCEED(1402, "文件大小超过限制"),

    // 其他业务错误状态码 15xx
    OPERATION_FAILED(1501, "操作失败"),
    DATA_ERROR(1502, "数据异常"),
    AUTHENTICATION_FAILED(1503, "认证失败"),
    REGISTER_FAILED(1504, "注册失败");

    private final Integer code;
    private final String message;

    ResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}